#!/usr/bin/python
# -*- coding: UTF-8 -*-

from xml.dom.minidom import parse
import xml.dom.minidom as MINIDOM


# 使用 minidom 打开 XML 文件
DOMTree = MINIDOM.parse("/home/lvmeng/PycharmProjects/cts_results_analysis/test_result.xml")
result = DOMTree.documentElement

if result.hasAttribute("suite_version"):
    print("Cts suit version: %s " % result.getAttribute("suite_version"))


summaries = result.getElementsByTagName("Summary")

for summary in summaries:
    # All modules
    summary_modules_total = summary.getAttribute("modules_total")
    # All complete modules
    summary_modules_done = summary.getAttribute("modules_done")
    # Failed cases count
    summary_failed = summary.getAttribute("failed")



    if summary_modules_done != summary_modules_total:
        print("Modules Total: %s " % summary_modules_total)
        print("Modules Done: %s " % summary_modules_done)
        if summary_failed == "0":
            print("0 case failed, but modules cannot complete.")
        else:
            print("Failed Count: %s " % summary_failed)
    else:
        print("test")





def __main():





# for module in modules:
#     moduleName = module.getAttribute("name")
#     moduleAbi = module.getAttribute("abi")
#     mod
#
#     print(case.getAttribute("name"))
#
#     caseName = case.getAttribute("name")

if __name__ == "__main__":
    __main()
